<template>
    <div>
        <div class="bg"></div>
        <div class="topList">
            <router-link to="/appmain" class="topBtn">
               <i class="iconfont arrow-left">&#xe641;</i><span>个人中心--密码修改</span>
            </router-link>
        </div>
        <div class="contentList">
            <div class="tipinfo">备注：个人密码修改</div>
            <div class="inputList">
                <el-input class="elinput" :disabled="true" placeholder="请输入手机号" v-model="phoneValue">
                    <template slot="prepend">手&nbsp;机&nbsp;号&nbsp;：</template>
                </el-input>
                <el-input type="password" class="elinput" placeholder="请输入新密码" v-model="pwdValue">
                    <template slot="prepend">新&nbsp;密&nbsp;码&nbsp;：</template>
                </el-input>
                <el-input type="password" class="elinput" placeholder="再次输入新密码" v-model="rePwdValue">
                    <template slot="prepend">确认密码：</template>
                </el-input>

                <el-button type="primary" class="btnSure" @click="insertgo">确定</el-button>
            </div>
      
        </div>
        <div class="bottombar">
            <router-link to='/appmain'>
                <img src="../../assets/app/home.png" alt="">
            </router-link>
            
        </div>
    </div>
</template>

<script>
export default {
  data() {
    return {
      phoneValue: "",
      pwdValue: "",
      rePwdValue: ""
    };
  },
  mounted() {
    this.phoneValue = JSON.parse(localStorage.getItem("studentinfo")).St_Phone; //学员信息
  },
  methods: {
    //提交密码
    insertgo() {
      if (this.pwdValue.trim() == "") {
        this.$message({
          message: "密码不能为空",
          center: "true",
          offset: 300
        });
        return false;
      }
      if (this.pwdValue.length < 8) {
        this.$message({
          message: "密码长度必须大于8位",
          center: "true",
          offset: 300
        });
        return false;
      }
      if (this.pwdValue.trim() == this.rePwdValue.trim()) {
        this.$axios
          .put("/AppLogin/V1", {
              St_Phone: this.phoneValue,
              St_pwd: this.pwdValue        
          })
          .then(Json => {
            if (Json.data == "ok") {
              this.$message({
                message: "修改成功",
                type: "success",
                center: "true",
                offset: 300
              });
            } else {
              this.$message({
                message: "修改失败！请重新尝试",
                type: "warning",
                center: "true",
                offset: 300
              });
            }
          })
          .catch(err => {
            this.$message.error({
              message: "网络错误！",
              center: "true",
              offset: 300
            });
          });
      } else {
        this.$message({
          message: "两次密码输入的不一致",
          center: "true",
          offset: 300
        });
        return false;
      }
    }
  }
};
</script>

<style scoped>
.bg {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  /* background-image: linear-gradient( 135deg, #0396FF 10%, #ABDCFF 100%); */
  z-index: -1;
  width: 100%;
  /* height: 10rem; */
  background: #ececec;
}
@font-face {
  font-family: "iconfont"; /* project id 1514769 */
  src: url("//at.alicdn.com/t/font_1514769_4qk754zzrki.eot");
  src: url("//at.alicdn.com/t/font_1514769_4qk754zzrki.eot?#iefix")
      format("embedded-opentype"),
    url("//at.alicdn.com/t/font_1514769_4qk754zzrki.woff2") format("woff2"),
    url("//at.alicdn.com/t/font_1514769_4qk754zzrki.woff") format("woff"),
    url("//at.alicdn.com/t/font_1514769_4qk754zzrki.ttf") format("truetype"),
    url("//at.alicdn.com/t/font_1514769_4qk754zzrki.svg#iconfont") format("svg");
}
.iconfont {
  font-family: "iconfont" !important;
  font-size: 25px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  vertical-align: sub;
}
.topList {
  height: 11rem;
  width: 100%;
  line-height: 2.5rem;
  /* border:1px solid red; */
  text-align: center;
  font-size: 18px;
  background-image: linear-gradient(135deg, #0396ff 10%, #abdcff 100%);
}
.topBtn {
  text-decoration: none;
  color: white;
  display: inline-block;
  width: 100%;
}
.arrow-left {
  float: left;
}
.contentList {
  width: 90%;
  margin: -7rem auto;
  height: 25rem;
  /* border:1px solid red; */
  border-radius: 10px;
  background: white;
}
.tipinfo {
  text-align: center;
  padding: 1.8rem 0;
  color: cornflowerblue;
  font-size: 15px;
}
.inputList {
  width: 90%;
  margin: 0 auto;
}
.elinput {
  margin: 0.5rem 0;
}
.btnSure {
  width: 100%;
  margin-top: 3rem;
}
.bottombar {
  position: fixed;
  z-index: 900;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  /* border: 1px solid white; */
  height: 50px;
  text-align: center;
 background: rgb(36, 164, 255);
  box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.1) inset;
}
.bottombar img {
  background: white;
  padding: 10px;
  border-radius: 50%;
  position: relative;
  /* top: -20px; */
  text-shadow: 0 1px rgba(0, 0, 0, 0.3);
  /* border: 5px solid gray; */
}
</style>
